﻿//
// Copyright (c) 2024 BPer
//
#ifndef BPerPushPublish_H
#define BPerPushPublish_H
#include <bperutil/buffer/BPerAudioEncoderBuffer.h>
#include <bperutil/buffer/BPerVideoEncoderBuffer.h>
#include <bperutil/buffer/BPerAudioBuffer.h>
#include <bperutil/buffer/BPerVideoBuffer.h>
#include <bperpush/BPerPushCapture.h>
#include <bperpush/BPerPushEncoder.h>
#include <bperpush/BPerRtcPublish.h>

class BPerPushPublish: public BPerSendRequestCallback {
public:
	BPerPushPublish(BPerContext *pcontext);
	virtual ~BPerPushPublish();

	void setCaptureType(int pct);

	void startCamera();

	void stopCamera();

	void setScreenInterval(int32_t pinterval);
	void setDrawmouse(bool isDraw);
	void setRtcNetBuffer(BPerRtcPublish *prr);

	void startPubVideo();
	void startPubAudio();
	void initAudioEncoding();
	void initVideoEncoding();
	void setVideoInfo(BPerVideoInfo *pvideo);
	int32_t startAudioCapture();
	int32_t startVideoCapture();


	void initVideoMeeting();
	void startAudioEncoding();
	void startVideoEncoding();
	void deleteVideoEncoding();
	void startAudioCaptureState();
	void startVideoCaptureState();

	void stopAudioCaptureState();
	void stopVideoCaptureState();
	void stopScreenCaptureState();
	BPerVideoBuffer* getPreVideoBuffer();

	BPerVideoBuffer* getOutPreVideoBuffer();
	BPerVideoBuffer* getOutVideoBuffer();
	void stopAll();
	void setInAudioBuffer(vector<BPerAudioPlayBuffer*> *pbuf);
	void change(int32_t st);

	void sendRequest(int32_t puid, uint32_t ssrc, BPerRequestType req);
	void sendMsgToEncoder(BPerRequestType req);
	BPerPushCapture* getPushCapture();
protected:

private:
	BPerVideoBuffer* m_outVideoBuffer;
	BPerVideoBuffer* m_outPreVideoBuffer;
private:
	BPerContext *m_context;
	BPerPushEncoder *m_encoder;
	BPerPushCapture *m_capture;

	BPerVideoInfo *m_videoInfo;
	int32_t isStartAudioCapture, isStartVideoCapture, isStartScreenCapture;
	int32_t isStartAudioEncoder, isStartVideoEncoder;
	void stopAudioState();
	void stopVideoState();
	void initCapture();
	int m_captureType;
};

#endif //
